//
//  KidTicketTipVIew.swift
//  AirTravel
//
//  Created by tulip on 2021/8/16.
//

import UIKit
import TangramKit

class KidTicketTipVIew: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor=UIColor.black.withAlphaComponent(0.6)
        let boxview=UIView.init(frame: CGRect(x: 0, y: 0.3*SCREEN_HEIGHT, width: SCREEN_WIDTH, height: 0.7*SCREEN_HEIGHT))
        boxview.backgroundColor=UIColor.white
        self.addSubview(boxview)
        
        let closeBtn=UIButton.init(frame: CGRect(x: SCREEN_WIDTH - 36, y: 19, width: 21, height: 21))
        closeBtn.setImage(UIImage(named: "图层14-close"), for: .normal)
        closeBtn.addTarget(self, action: #selector(close), for: .touchUpInside)
        boxview.addSubview(closeBtn)
        
        let title=UILabel.init(frame: CGRect(x: SCREEN_WIDTH/2.0-100, y: 55, width: 200, height: 14))
        title.text="儿童婴儿票预定说明"
        title.textColor=UIColor.init(hexString: "ff8a00")
        title.textAlignment = .center
        title.font=UIFont.boldSystemFont(ofSize: 15)
        boxview.addSubview(title)
        
        let  line=UIView.init(frame: CGRect(x: 0, y: 78, width: SCREEN_WIDTH, height: 1))
        line.backgroundColor=UIColor.init(hexString: "ebebeb")
        boxview.addSubview(line)
        
        let scrollview=UIScrollView.init(frame: CGRect(x: 0, y: 80, width: ScreenWidth, height: boxview.frame.size.height-80))
        boxview.addSubview(scrollview)
        scrollview.bounces=false
        scrollview.showsVerticalScrollIndicator=false
        
        let tgview=TGLinearLayout.init(.vert)
        scrollview.addSubview(tgview)
        tgview.tg_top.equal(0)
        tgview.tg_left.equal(0)
        tgview.tg_width.equal(ScreenWidth)
        tgview.tg_height.equal(.wrap)

        let titlebox1=UIView.init()
        tgview.addSubview(titlebox1)
        titlebox1.tg_top.equal(30)
        titlebox1.tg_left.equal(0)
        titlebox1.tg_width.equal(SCREEN_WIDTH)
        titlebox1.tg_height.equal(16)


        let  titleLine1=UIView.init(frame: CGRect(x: 15, y: 5, width: 5, height: 6))
        titleLine1.backgroundColor=UIColor.init(hexString: "ff8e4a")
        titlebox1.addSubview(titleLine1)

        let title1=UILabel.init(frame: CGRect(x: 26, y: 0, width: SCREEN_WIDTH-26, height: 16))
        title1.text="婴儿票(14天-2岁)"
        title1.textColor=UIColor.init(hexString: "333333")
        title1.font=UIFont.boldSystemFont(ofSize: 17)
        titlebox1.addSubview(title1)
        
        let content1=UILabel.init()
        
        content1.text="1. 使用婴儿票的乘客：登机当天应满14天但未满2周岁，出生未满14天的婴儿或出生未满90天的早产婴儿不能乘机。\n2. 婴儿购票可用证件包括身份证、护照、户口薄、出生证明等。\n3. 婴儿票价格按照成人标准价（全价）的10%，不收机建及燃油费，无座位。"
        content1.textColor=UIColor.init(hexString: "666666")
        content1.font=UIFont.systemFont(ofSize: 13)
        content1.numberOfLines=0
        tgview.addSubview(content1)
        content1.tg_top.equal(15)
        content1.tg_left.equal(15)
        content1.tg_width.equal(SCREEN_WIDTH-30)
        content1.tg_height.equal(.wrap)
        
    
        let titlebox2=UIView.init()
        tgview.addSubview(titlebox2)
        titlebox2.tg_top.equal(30)
        titlebox2.tg_left.equal(0)
        titlebox2.tg_width.equal(SCREEN_WIDTH)
        titlebox2.tg_height.equal(16)


        let  titleLine2=UIView.init(frame: CGRect(x: 15, y: 5, width: 5, height: 6))
        titleLine2.backgroundColor=UIColor.init(hexString: "ff8e4a")
        titlebox2.addSubview(titleLine2)

        let title2=UILabel.init(frame: CGRect(x: 26, y: 0, width: SCREEN_WIDTH-26, height: 16))
        title2.text="儿童票(2岁-12岁)"
        title2.textColor=UIColor.init(hexString: "333333")
        title2.font=UIFont.boldSystemFont(ofSize: 17)
        titlebox2.addSubview(title2)
        
        let content2=UILabel.init()
        
        content2.text="1. 使用儿童票的乘客：登机当天应满2周岁但未满12周岁。\n2. 儿童可凭户口本登机，订票时应准确填写户口本上登记的身份证号。\n3. 目前暂不支持儿童单独订票，无人陪伴儿童请与航空公司联系购票。\n4. 儿童购买成人票，登机时可能存在风险，请先和代理商咨询确认。"
        content2.textColor=UIColor.init(hexString: "666666")
        content2.font=UIFont.systemFont(ofSize: 13)
        content2.numberOfLines=0
        tgview.addSubview(content2)
        content2.tg_left.equal(15)
        content2.tg_width.equal(SCREEN_WIDTH-30)
        content2.tg_height.equal(.wrap)
        
        scrollview.contentSize=CGSize(width: SCREEN_WIDTH, height: tgview.frame.size.height)
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func close(){
        self.removeFromSuperview()
    }
    
}
